module pure_func

    implicit none
    integer :: d = 0

contains

    pure subroutine max1(a, b, c)
        integer, intent(in) :: a, b
        integer, intent(out) :: c

        c = max(a, b)

    end subroutine max1

    impure subroutine max2(a, b, c)
        integer, intent(in) :: a, b
        integer, intent(out) :: c

        c = max(a, b)
        d = c

    end subroutine max2

end module pure_func

program main

    use pure_func
    implicit none
    integer :: c

    call max1(1, 2, c)
    print *, c, d

    call max2(1, 2, c)
    print *, c, d

end program main
